<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "shbb_crop".
 *
 * @property integer $id
 * @property string $code
 * @property string $name
 * @property string $image
 * @property integer $start_time
 * @property string $comment
 * @property integer $park_id
 *
 * @property Park $park
 */
class Crop extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shbb_crop';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'start_time', 'park_id'], 'integer'],
            [['code'], 'unique'],
            [['code', 'name', 'image', 'comment'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '作物ID',
            'code' => '作物编号',
            'name' => '作物名称',
            'image' => '作物图片',
            'start_time' => '初产时间',
            'comment' => '备注',
            'park_id' => '所属园区',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPark()
    {
        return $this->hasOne(Park::className(), ['id' => 'park_id']);
    }
}
